//
//  NSattributedString+Extension.swift
//  微博
//
//  Created by 程双岐 on 16/10/7.
//  Copyright © 2016年 heima. All rights reserved.
//

import UIKit
extension NSAttributedString{
    
    static func attributedStringWithEmoticon(emoticon: HMEmoticon,font: UIFont) -> NSAttributedString{
        let image = UIImage(named: emoticon.path!)
        
        let attachment = HMTextAttachment()
        attachment.emoticon = emoticon
  
        
        
        let lineHeight = font.lineHeight
        
        
        attachment.bounds = CGRect(x: 0, y: -4, width: lineHeight, height: lineHeight)
        attachment.image = image
        
        let attributedstr = NSAttributedString(attachment: attachment)
        
        return attributedstr
    }
    
}
